package com.cn.medicalcare.controller.backstageservlet.login;

import com.cn.medicalcare.customtool.JedisUtil;
import org.apache.commons.lang3.StringUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import java.io.IOException;

@WebServlet("/backstage/logout.json")
public class LogoutServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String token = req.getParameter("sessionId");
        if (StringUtils.isNotEmpty(token))
            JedisUtil.jedisDo(j -> {
                j.select(15);
                return j.del(token);
            });
    }
}
